select(_, []) :- fail.
select(X, [H|T]) :- X = H; select(X, T).

get_cars_by_brand([], _, Expected_cars) :- Expected_cars = [].
get_cars_by_brand(Cars, Brand, Expected_cars) :-
	select(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, Cars),
	((H1 == Brand,
		delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		get_cars_by_brand(T, Brand, List),
		Expected_cars = [H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|List]);
	(delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		get_cars_by_brand(T, Brand, List),
		Expected_cars = List)).

get_cars_by_model([], _, Expected_cars) :- Expected_cars = [].
get_cars_by_model(Cars, Model, Expected_cars) :-
	select(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, Cars),
	((H2 == Model,
		delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		get_cars_by_model(T, Model, List),
		Expected_cars = [H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|List]);
	(delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		get_cars_by_model(T, Model, List),
		Expected_cars = List)).

get_cars_by_budget([], _, Expected_cars) :- Expected_cars = [].
get_cars_by_budget(Cars, Budget, Expected_cars) :-
	select(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, Cars),
	Threshold is Budget / 10,
	((H11 - Budget =< Threshold, H11 - Budget >= -Threshold,
		delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		get_cars_by_budget(T, Budget, List),
		Expected_cars = [H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|List]);
	(delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		get_cars_by_budget(T, Budget, List),
		Expected_cars = List)).

get_cars_by_emission([], _, Expected_cars) :- Expected_cars = [].
get_cars_by_emission(Cars, Emission, Expected_cars) :-
	select(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, Cars),
	((H4 - Emission =< 200, H4 - Emission >= -200,
		delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		get_cars_by_emission(T, Emission, List),
		Expected_cars = [H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|List]);
	(delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		get_cars_by_emission(T, Emission, List),
		Expected_cars = List)).

get_cars_by_vehicle_type([], _, Expected_cars) :- Expected_cars = [].
get_cars_by_vehicle_type(Cars, Vehicle_type, Expected_cars) :-
	select(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, Cars),
	((H3 = Vehicle_type,
		delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		get_cars_by_vehicle_type(T, Vehicle_type, List),
		Expected_cars = [H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|List]);
	(delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		get_cars_by_vehicle_type(T, Vehicle_type, List),
		Expected_cars = List)).

get_cars_by_max_speed([], _, Expected_cars) :- Expected_cars = [].
get_cars_by_max_speed(Cars, Max_speed, Expected_cars) :-
	select(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, Cars),
	((H6 - Max_speed =< 15, H6 - Max_speed >= -15,
		delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		get_cars_by_max_speed(T, Max_speed, List),
		Expected_cars = [H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|List]);
	(delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		get_cars_by_max_speed(T, Max_speed, List),
		Expected_cars = List)).

get_cars_by_length([], _, Expected_cars) :- Expected_cars = [].
get_cars_by_length(Cars, Length, Expected_cars) :-
	select(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, Cars),
	((H8 - Length =< 300, H8 - Length >= -300,
		delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		get_cars_by_length(T, Length, List),
		Expected_cars = [H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|List]);
	(delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		get_cars_by_length(T, Length, List),
		Expected_cars = List)).

get_cars_by_width([], _, Expected_cars) :- Expected_cars = [].
get_cars_by_width(Cars, Width, Expected_cars) :-
	select(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, Cars),
	((H9 - Width =< 100, H9 - Width >= -100,
		delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		get_cars_by_width(T, Width, List),
		Expected_cars = [H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|List]);
	(delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		get_cars_by_width(T, Width, List),
		Expected_cars = List)).

get_cars_by_height([], _, Expected_cars) :- Expected_cars = [].
get_cars_by_height(Cars, Height, Expected_cars) :-
	select(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, Cars),
	((H10 - Height =< 100, H10 - Height >= -100,
		delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		get_cars_by_height(T, Height, List),
		Expected_cars = [H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|List]);
	(delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		get_cars_by_height(T, Height, List),
		Expected_cars = List)).

find_expected_car([], _, _, _, _, _, _, _, _).
find_expected_car([H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|T], Brand, Budget, Emission, Vehicle_type, Max_speed, Length, Width, Height) :-
	(H1 = Brand,
		H3 = Vehicle_type,
		H4 - Emission =< 200, H4 - Emission >= -200,
		H6 - Max_speed =< 15, H6 - Max_speed >= -15,
		H8 - Length =< 300, H8 - Length >= -300,
		H9 - Width =< 100, H9 - Width >= -100,
		H10 - Height =< 100, H10 - Height >= -100,
		Threshold is Budget / 10,
		H11 - Budget =< Threshold, H11 - Budget >= -Threshold,
		write_line(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11),
		find_expected_car(T, Brand, Budget, Emission, Vehicle_type, Max_speed, Length, Width, Height));
	find_expected_car(T, Brand, Budget, Emission, Vehicle_type, Max_speed, Length, Width, Height).

compute_budget_diff([], _).
compute_budget_diff([H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|T], Budget) :-
	write_line(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11),
	write('Price is '),
	write(H11),
	Threshold is Budget / 10,
	((H11 > Budget,
		Diff is H11 - Budget,
		write(', difference is '),
		write(Diff),
		((Diff =< Threshold,
			writeln(', good choice on price.'));
		writeln(', bad choice on price.')));
	(H11 < Budget,
		Diff is Budget - H11,
		write(', difference is '),
		write(Diff),
		((Diff =< Threshold,
			writeln(', good choice on price.'));
		writeln(', bad choice on price.')));
	(H11 = Budget,
		writeln(', no difference, good choice on price.'))),
	compute_budget_diff(T, Budget).

compute_emission_diff([], _).
compute_emission_diff([H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|T], Emission) :-
	write_line(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11),
	write('Emission is '),
	write(H4),
	((H4 > Emission,
		Diff is H4 - Emission,
		write(', difference is '),
		write(Diff),
		((Diff =< 200,
			writeln(', good choice on emission.'));
		writeln(', bad choice on emission.')));
	(H4 < Emission,
		Diff is Emission - H4,
		write(', difference is '),
		write(Diff),
		((Diff =< 200,
			writeln(', good choice on emission.'));
		writeln(', bad choice on emission.')));
	(H4 = Emission,
		writeln(', no difference, good choice on emission.'))),
	compute_emission_diff(T, Emission).

compute_max_speed_diff([], _).
compute_max_speed_diff([H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|T], Max_speed) :-
	write_line(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11),
	write('Max speed is '),
	write(H6),
	((H6 > Max_speed,
		Diff is H6 - Max_speed,
		write(', difference is '),
		write(Diff),
		((Diff =< 15,
			writeln(', good choice on max speed.'));
		writeln(', bad choice on max speed.')));
	(H6 < Max_speed,
		Diff is Max_speed - H6,
		write(', difference is '),
		write(Diff),
		((Diff =< 15,
			writeln(', good choice on max speed.'));
		writeln(', bad choice on max speed.')));
	(H6 = Max_speed,
		writeln(', no difference, good choice on max speed.'))),
	compute_max_speed_diff(T, Max_speed).

compute_length_diff([], _).
compute_length_diff([H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|T], Length) :-
	write_line(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11),
	write('Length is '),
	write(H8),
	((H8 > Length,
		Diff is H8 - Length,
		write(', difference is '),
		write(Diff),
		((Diff =< 300,
			writeln(', good choice on length.'));
		writeln(', bad choice on length.')));
	(H8 < Length,
		Diff is Length - H8,
		write(', difference is '),
		write(Diff),
		((Diff =< 300,
			writeln(', good choice on length.'));
		writeln(', bad choice on length.')));
	(H8 = Length,
		writeln(', no difference, good choice on length.'))),
	compute_length_diff(T, Length).

compute_width_diff([], _).
compute_width_diff([H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|T], Width) :-
	write_line(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11),
	write('Width is '),
	write(H9),
	((H9 > Width,
		Diff is H9 - Width,
		write(', difference is '),
		write(Diff),
		((Diff =< 100,
			writeln(', good choice on width.'));
		writeln(', bad choice on width.')));
	(H9 < Width,
		Diff is Width - H9,
		write(', difference is '),
		write(Diff),
		((Diff =< 100,
			writeln(', good choice on width.'));
		writeln(', bad choice on width.')));
	(H9 = Width,
		writeln(', no difference, good choice on width.'))),
	compute_width_diff(T, Width).

compute_height_diff([], _).
compute_height_diff([H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|T], Height) :-
	write_line(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11),
	write('Height is '),
	write(H10),
	((H10 > Height,
		Diff is H10 - Height,
		write(', difference is '),
		write(Diff),
		((Diff =< 100,
			writeln(', good choice on height.'));
		writeln(', bad choice on height.')));
	(H10 < Height,
		Diff is Height - H10,
		write(', difference is '),
		write(Diff),
		((Diff =< 100,
			writeln(', good choice on height.'));
		writeln(', bad choice on height.')));
	(H10 = Height,
		writeln(', no difference, good choice on height.'))),
	compute_height_diff(T, Height).

recommend_big_cars([], Expected_cars) :- Expected_cars = [].
recommend_big_cars(Cars, Expected_cars) :-
	select(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, Cars),
	Car_size is H8*H9*H10,
	((Car_size >= 11200000000, 
		delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		recommend_big_cars(T, List),
		Expected_cars = [H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|List]);
	(delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		recommend_big_cars(T, List),
		Expected_cars = List)).

recommend_small_cars([], Expected_cars) :- Expected_cars = [].
recommend_small_cars(Cars, Expected_cars) :-
	select(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, Cars),
	Car_size is H8*H9*H10,
	((Car_size < 11200000000, 
		delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		recommend_small_cars(T, List),
		Expected_cars = [H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|List]);
	(delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		recommend_small_cars(T, List),
		Expected_cars = List)).

recommend_imported_cars([], Expected_cars) :- Expected_cars = [].
recommend_imported_cars(Cars, Expected_cars) :-
	select(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, Cars),
	((
		((H1 = audi, (H2 = a3; H2 = a4; H2 = a6));
			(H1 = bmw, (H2 = 1; H2 = 2; H2 = 3; H2 = 5; H2 = x1));
			H1 = mercedes_benz;
			H1 = porsche;
			H1 = ferrari;
			H1 = lamborghini;
			H1 = maserati;
			H1 = aston_martin;
			H1 = bentley;
			H1 = lincoln;
			H1 = rolls_royce),
		delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		recommend_imported_cars(T, List),
		Expected_cars = [H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|List]);
	(delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		recommend_imported_cars(T, List),
		Expected_cars = List)).

recommend_homemade_cars([], Expected_cars) :- Expected_cars = [].
recommend_homemade_cars(Cars, Expected_cars) :-
	select(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, Cars),
	((
		((H1 = audi, (H2 = a1; H2 = a2; H2 = a5; H2 = a7; H2 = a8));
			(H1 = bmw, (H2 = 4; H2 = 6; H2 = 7; H2 = x2; H2 = x3; H2 = x4; H2 = x5; H2 = x6));
			H1 = infiniti;
			H1 = lexus;
			H1 = honda;
			H1 = mazda;
			H1 = land_rover;
			H1 = chevrolet),
		delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		recommend_homemade_cars(T, List),
		Expected_cars = [H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|List]);
	(delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		recommend_homemade_cars(T, List),
		Expected_cars = List)).

recommend_highspeed_cars([], Expected_cars) :- Expected_cars = [].
recommend_highspeed_cars(Cars, Expected_cars) :-
	select(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, Cars),
	((H6 >= 250, 
		delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		recommend_highspeed_cars(T, List),
		Expected_cars = [H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|List]);
	(delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		recommend_highspeed_cars(T, List),
		Expected_cars = List)).

recommend_lowspeed_cars([], Expected_cars) :- Expected_cars = [].
recommend_lowspeed_cars(Cars, Expected_cars) :-
	select(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, Cars),
	((H6 < 250, 
		delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		recommend_lowspeed_cars(T, List),
		Expected_cars = [H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|List]);
	(delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		recommend_lowspeed_cars(T, List),
		Expected_cars = List)).

recommend_homeuse_cars([], Expected_cars) :- Expected_cars = [].
recommend_homeuse_cars(Cars, Expected_cars) :-
	select(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, Cars),
	(((H3 = hatchback; H3 = notchback; H3 = mpv; H3 = suv), 
		delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		recommend_homeuse_cars(T, List),
		Expected_cars = [H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|List]);
	(delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		recommend_homeuse_cars(T, List),
		Expected_cars = List)).

recommend_travel_cars([], Expected_cars) :- Expected_cars = [].
recommend_travel_cars(Cars, Expected_cars) :-
	select(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, Cars),
	(((H3 = wagon; H3 = mpv; H3 = suv), 
		delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		recommend_travel_cars(T, List),
		Expected_cars = [H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|List]);
	(delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		recommend_travel_cars(T, List),
		Expected_cars = List)).

recommend_race_cars([], Expected_cars) :- Expected_cars = [].
recommend_race_cars(Cars, Expected_cars) :-
	select(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, Cars),
	(((H3 = htc; H3 = htr; H3 = str), 
		delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		recommend_race_cars(T, List),
		Expected_cars = [H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|List]);
	(delete(Cars, H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11, T),
		recommend_race_cars(T, List),
		Expected_cars = List)).
	
compare_two_cars([], _, _).
compare_two_cars([H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|T], B1-M1-T1, B2-M2-T2) :-
	(H1 = B1,
		H2 = M1,
		H3 = T1,
		write_line(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11),
		compare_two_cars(T, B1-M1-T1, B2-M2-T2));
	(H1 = B2,
		H2 = M2,
		H3 = T2,
		write_line(H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11),
		compare_two_cars(T, B1-M1, B2-M2));
	compare_two_cars(T, B1-M1-T1, B2-M2-T2).

interchange_emission([], I_cars) :- I_cars = [].
interchange_emission([H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|T], I_cars) :-
	interchange_emission(T, List),
	I_cars = [H4-H1-H2-H3-H5-H6-H7-H8-H9-H10-H11|List].

interchange_max_speed([], I_cars) :- I_cars = [].
interchange_max_speed([H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|T], I_cars) :-
	interchange_max_speed(T, List),
	I_cars = [H6-H1-H2-H3-H4-H5-H7-H8-H9-H10-H11|List].

interchange_budget([], I_cars) :- I_cars = [].
interchange_budget([H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|T], I_cars) :-
	interchange_budget(T, List),
	I_cars = [H11-H1-H2-H3-H4-H5-H6-H7-H8-H9-H10|List].

interchange_length([], I_cars) :- I_cars = [].
interchange_length([H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|T], I_cars) :-
	interchange_length(T, List),
	I_cars = [H8-H1-H2-H3-H4-H5-H6-H7-H9-H10-H11|List].

interchange_width([], I_cars) :- I_cars = [].
interchange_width([H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|T], I_cars) :-
	interchange_width(T, List),
	I_cars = [H9-H1-H2-H3-H4-H5-H6-H7-H8-H10-H11|List].

interchange_height([], I_cars) :- I_cars = [].
interchange_height([H1-H2-H3-H4-H5-H6-H7-H8-H9-H10-H11|T], I_cars) :-
	interchange_height(T, List),
	I_cars = [H10-H1-H2-H3-H4-H5-H6-H7-H8-H9-H11|List].

load() :-
	consult('loader.pl'),
	consult('interactor.pl').

run :-
	load(),
	load_car_info(Cars),
	select_function(Ans),
	((Ans = 1,
		fuzzy_or_precise(Ans2),
		((Ans2 = 1,
			ask_aspect(A1, A2, A3, A4, A5, A6, A7, A8),
			((A1 = 1,
				ask_brand(Brand),
				get_cars_by_brand(Cars, Brand, Cars1), !);
			(A1 = 2,
				Cars1 = Cars)),
			((A2 = 1,
				ask_budget(Budget),
				get_cars_by_budget(Cars1, Budget, Cars2), !);
			(A2 = 2,
				Cars2 = Cars1)),
			((A3 = 1,
				ask_emission(Emission),
				get_cars_by_emission(Cars2, Emission, Cars3), !);
			(A3 = 2,
				Cars3 = Cars2)),
			((A4 = 1,
				ask_vehicle_type(Vehicle_type),
				get_cars_by_vehicle_type(Cars3, Vehicle_type, Cars4), !);
			(A4 = 2,
				Cars4 = Cars3)),
			((A5 = 1,
				ask_max_speed(Max_speed),
				get_cars_by_max_speed(Cars4, Max_speed, Cars5), !);
			(A5 = 2,
				Cars5 = Cars4)),
			((A6 = 1,
				ask_length(Length),
				get_cars_by_length(Cars5, Length, Cars6), !);
			(A6 = 2,
				Cars6 = Cars5)),
			((A7 = 1,
				ask_width(Width),
				get_cars_by_width(Cars6, Width, Cars7), !);
			(A7 = 2,
				Cars7 = Cars6)),
			((A8 = 1,
				ask_height(Height),
				get_cars_by_height(Cars7, Height, Cars8), !);
			(A8 = 2,
				Cars8 = Cars7)),
			write_list(Cars8));
		(Ans2 = 2,
			get_expected_car_info(Brand, Budget, Emission, Vehicle_type, Max_speed, Length, Width, Height),
			find_expected_car(Cars, Brand, Budget, Emission, Vehicle_type, Max_speed, Length, Width, Height)))
		);
	(Ans = 2,
		input_one_model(B1-M1-T1),
		get_cars_by_brand(Cars, B1, Cars1), !,
		get_cars_by_model(Cars1, M1, Cars2), !,
		get_cars_by_vehicle_type(Cars2, T1, Cars3), !,
		ask_valued(A1, A2, A3, A4, A5, A6),
		((A1 = 1,
			ask_budget(Budget),
			compute_budget_diff(Cars3, Budget));
		A1 = 2),
		((A2 = 1,
			ask_emission(Emission),
			compute_emission_diff(Cars3, Emission));
		A2 = 2),
		((A3 = 1,
			ask_max_speed(Max_speed),
			compute_max_speed_diff(Cars3, Max_speed));
		A3 = 2),
		((A4 = 1,
			ask_length(Length),
			compute_length_diff(Cars3, Length));
		A4 = 2),
		((A5 = 1,
			ask_width(Width),
			compute_width_diff(Cars3, Width));
		A5 = 2),
		((A6 = 1,
			ask_height(Height),
			compute_height_diff(Cars3, Height));
		A6 = 2)
		);
	(Ans = 3,
		recommend(Size, Imported, Speeding, Purpose),
		((Size = 1, recommend_big_cars(Cars, Cars1), !);
			(Size = 2, recommend_small_cars(Cars, Cars1), !)),
		((Imported = 1, recommend_imported_cars(Cars1, Cars2), !);
			(Imported = 2, recommend_homemade_cars(Cars1, Cars2), !)),
		((Speeding = 1, recommend_highspeed_cars(Cars2, Cars3), !);
			(Speeding = 2, recommend_lowspeed_cars(Cars2, Cars3), !)),
		((Purpose = 1, recommend_homeuse_cars(Cars3, Cars4), !);
			(Purpose = 2, recommend_travel_cars(Cars3, Cars4), !);
			(Purpose = 3, recommend_race_cars(Cars3, Cars4), !)),
		write_list(Cars4));
	(Ans = 4,
		input_two_models(B1-M1-T1, B2-M2-T2),
		compare_two_cars(Cars, B1-M1-T1, B2-M2-T2));
	(Ans = 5,
		ask_brand(Brand),
		get_cars_by_brand(Cars, Brand, Cars1), !,
		sort_by_aspect(Ans2),
		((Ans2 = 1,
			interchange_emission(Cars1, I_cars),
			sort(I_cars, Sorted_cars),
			write_list_by_emission(Sorted_cars));
		(Ans2 = 2,
			interchange_max_speed(Cars1, I_cars),
			sort(I_cars, Sorted_cars),
			write_list_by_max_speed(Sorted_cars));
		(Ans2 = 3,
			interchange_budget(Cars1, I_cars),
			sort(I_cars, Sorted_cars),
			write_list_by_budget(Sorted_cars));
		(Ans2 = 4,
			interchange_length(Cars1, I_cars),
			sort(I_cars, Sorted_cars),
			write_list_by_length(Sorted_cars));
		(Ans2 = 5,
			interchange_width(Cars1, I_cars),
			sort(I_cars, Sorted_cars),
			write_list_by_width(Sorted_cars));
		(Ans2 = 6,
			interchange_height(Cars1, I_cars),
			sort(I_cars, Sorted_cars),
			write_list_by_height(Sorted_cars))))).